package com.yuantu.judiciary.dao;

import com.yuantu.judiciary.model.domain.InvoiceInfoDO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 开票信息
 *
 * @author syw
 * @since 2023-08-21
 **/
public interface IInvoiceInfoDao extends JpaRepository<InvoiceInfoDO, Long> {

    InvoiceInfoDO findInvoiceInfoByOrderIdAndDeletedFalse(Long orderId);

    @Query("select distinct i.orderId from InvoiceInfoDO i where i.orderId in (:orderIds) and i.deleted = false ")
    List<Long> getOrderIds(List<Long> orderIds);

    Page<InvoiceInfoDO> findInvoiceInfoByCreatorIdAndDeletedFalse(Long creatorId, Pageable pageable);

    List<InvoiceInfoDO> findInvoiceInfoByOrderIdInAndDeletedFalse(List<Long> orderId);

    InvoiceInfoDO findInvoiceInfoByIdAndDeletedFalse(Long id);

}
